<html>
<body>

<?php
include ("opdClass.php");

 $obj = new opdClass();
 
 if(isset($_REQUEST["opd_case_id"]) && isset($_REQUEST["opd_case_name"]) && isset($_REQUEST["opd_case_category"])){
	  	$opd_case_id = $_REQUEST["opd_case_id"];
		$opd_case_name = $_REQUEST["opd_case_name"];
		$opd_case_category = $_REQUEST["opd_case_category"];
		
		$obj->update_opd_case($opd_case_id, $opd_case_name, $opd_case_category);
		header('Location:getlist.php');
	}	
	
	else if(isset($_REQUEST["opd_case_id"]) && !isset($_REQUEST["opd_case_name"]) && !isset($_REQUEST["opd_case_category"])){
		$opd_case_id = $_REQUEST["opd_case_id"];
		$obj->get_opd_case($opd_case_id);
		$row = $obj->fetch();

		$opd_case_name = $row["opd_case_name"];
		$opd_case_category = $row["opd_case_category"];
	}

	else{
		echo ("Error");
		exit();
	}
 
?>

 <form action="opd_case_update.php" method="POST"><br>
 Case ID: <input type = "number" name = "opd_case_id"  value = "<?php echo $opd_case_id ?> " readonly> </br>
 Case Name: <input type="text" name="opd_case_name" value= "<?php echo $row["opd_case_name"] ?>"><br>
 Case Category: <input type="text" name= "opd_case_category" value ="<?php echo $row ["opd_case_category"] ?>"><br>
 <input type="submit" name="update" value="UPDATE">
 </form>
 
</body>
</html>